package com.dongdongshop.mq;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.pojo.TbItem;
import com.dongdongshop.service.EsServiceI;
import com.dongdongshop.service.TbItemServiceI;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RocketMQMessageListener(consumerGroup = "my-consumer",topic = "CCTV",messageModel = MessageModel.BROADCASTING)
public class ConsumeLinster implements RocketMQListener<Long> {
    @Reference(check=false ,timeout=1006666)
    private EsServiceI esService;

    @Reference(check=false ,timeout=1006666)
    private TbItemServiceI itemService;



    @Override
    public void onMessage(Long goodsId) {
        System.out.println("消息消费成功{}{}" + goodsId);
        List<TbItem> items = itemService.selectItemByGoodsId(goodsId);
        esService.addEs(items);
    }
}

